package cn.gok;

import java.util.Calendar;

public class Calendar类 {
    public static void main(String[] args) {
        常用方法();
    }

    private static void 常用方法() {
        //获取当前时间
        //Calendar calendar = Calendar.getInstance();
        Calendar calendar = Calendar.getInstance();
        //获取各种时间的单位
        int year = calendar.get(Calendar.YEAR);
        //月份从0开始计算
        int month = calendar.get(Calendar.MONTH)+1;
        //日
        int date = calendar.get(Calendar.DAY_OF_MONTH);
        //星期几
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK)-1;
        System.out.println(year+" "+month+" "+date+" "+dayOfWeek);
        //判断今年是不是闰年
        if (calendar.getActualMaximum(Calendar.DAY_OF_YEAR)==366){
            System.out.println("闰年");
        }else {
            System.out.println("平年");
        }
        //修改时间
        calendar.set(2000,1,1);
        calendar.add(Calendar.MONTH,2);
    }
}
